<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"adoontheway.gitee.io","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="这是最近做使用python的过程中遇到的一些问题和知识点笔记">
<meta property="og:type" content="article">
<meta property="og:title" content="每天进步一点点030 - 最近使用Python的一些笔记">
<meta property="og:url" content="https://adoontheway.gitee.io/2022/03/27/everydayprogress030/index.html">
<meta property="og:site_name" content="Ados">
<meta property="og:description" content="这是最近做使用python的过程中遇到的一些问题和知识点笔记">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-03-27T03:58:20.000Z">
<meta property="article:modified_time" content="2022-03-27T04:06:23.345Z">
<meta property="article:author" content="ado">
<meta property="article:tag" content="python">
<meta property="article:tag" content="tornado">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://adoontheway.gitee.io/2022/03/27/everydayprogress030/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>每天进步一点点030 - 最近使用Python的一些笔记 | Ados</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Ados</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">a fullstack game worker</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>

  <a href="https://github.com/adoontheway" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="external nofollow noopener noreferrer" target="_blank"><svg width="80" height="80" viewbox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://adoontheway.gitee.io/2022/03/27/everydayprogress030/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="ado">
      <meta itemprop="description" content="me, robot.">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Ados">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          每天进步一点点030 - 最近使用Python的一些笔记
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2022-03-27 11:58:20 / 修改时间：12:06:23" itemprop="dateCreated datePublished" datetime="2022-03-27T11:58:20+08:00">2022-03-27</time>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span>
            <div class="post-description">这是最近做使用python的过程中遇到的一些问题和知识点笔记</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="心得"><a href="#心得" class="headerlink" title="心得"></a>心得</h1><p>今天看了下 <strong>github/awsome-go</strong> ，发现以前真的是死心眼，凡事自己死磕，而不是去看看网上成熟的解决方案。<br>现在有很多 <strong>awsome-xxxx</strong> 在效率优先的情况下，没必要去死磕，重复造轮子啊。</p>
<h2 id="ImportError-No-module-named-xxxxx"><a href="#ImportError-No-module-named-xxxxx" class="headerlink" title="ImportError: No module named xxxxx"></a>ImportError: No module named xxxxx</h2><figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">py_module = __import__(name = module_file_path)</span><br><span class="line">ImportError: No module named xxxxx.xxxxxxx</span><br></pre></td></tr></table></figure>
<p>在需要导入的模组的文件里加入空的 <code>__init__.py</code> 就好了</p>
<h2 id="tornado-queuetornado-queue"><a href="#tornado-queuetornado-queue" class="headerlink" title="tornado.queuetornado.queue"></a>tornado.queuetornado.queue</h2><p><code>tornado.queue</code>为了协程实现了异步生产者/消费者模式，和<em>Python</em>自带的<strong>queue</strong>为线程而实现的一样。<br><code>Queue.get</code>会有一个协程专门等到队列中有数据。如果队列满了，会有专门的协程等待<code>Queue.put</code>争取到空间。<br><code>Queue</code>维护了一定数量的未完成的任务，数量从0开始，<code>put</code>会增加数量,<code>task_done</code>会减少数量。</p>
<h2 id="tornado-web应用的结构"><a href="#tornado-web应用的结构" class="headerlink" title="tornado web应用的结构"></a>tornado web应用的结构</h2><p><em>Tornado</em> web应用是由多个 <code>RequestHandler</code> 子类，一个用于将进来的请求路由到对应的处理的 <code>Application</code>， 一个用来启动的 <code>main()</code> 组成的</p>
<h2 id="setproctitle"><a href="#setproctitle" class="headerlink" title="setproctitle"></a>setproctitle</h2><p>修改进程名用的</p>
<h2 id="struct"><a href="#struct" class="headerlink" title="struct"></a>struct</h2><p>和lua类似的字节流封装</p>
<h3 id="头字符：表示字节顺序，大小和对齐方式"><a href="#头字符：表示字节顺序，大小和对齐方式" class="headerlink" title="头字符：表示字节顺序，大小和对齐方式"></a>头字符：表示字节顺序，大小和对齐方式</h3><table>
<thead>
<tr>
<th>字符</th>
<th>字节顺序</th>
<th>大小</th>
<th>对齐方式</th>
</tr>
</thead>
<tbody><tr>
<td>@</td>
<td>按原字节</td>
<td>按原字节</td>
<td>按原字节</td>
</tr>
<tr>
<td>=</td>
<td>按原字节</td>
<td>标准</td>
<td>无</td>
</tr>
<tr>
<td>&lt;</td>
<td>小端</td>
<td>标准</td>
<td>无</td>
</tr>
<tr>
<td>&gt;</td>
<td>大端</td>
<td>标准</td>
<td>无</td>
</tr>
<tr>
<td>!</td>
<td>网络（=大端）</td>
<td>标准</td>
<td>无</td>
</tr>
</tbody></table>
<h3 id="格式字符"><a href="#格式字符" class="headerlink" title="格式字符"></a>格式字符</h3><table>
<thead>
<tr>
<th>格式</th>
<th>C 类型</th>
<th>Python 类型</th>
<th>标准大小</th>
<th>注释</th>
</tr>
</thead>
<tbody><tr>
<td>x</td>
<td>填充字节</td>
<td>无</td>
<td></td>
<td></td>
</tr>
<tr>
<td>c</td>
<td>char</td>
<td>string of length 1</td>
<td>1</td>
<td></td>
</tr>
<tr>
<td>b</td>
<td>signed char</td>
<td>整数</td>
<td>1</td>
<td>(3)</td>
</tr>
<tr>
<td>B</td>
<td>unsigned char</td>
<td>整数</td>
<td>1</td>
<td>(3)</td>
</tr>
<tr>
<td>?</td>
<td>_Bool</td>
<td>bool</td>
<td>1</td>
<td>(1)</td>
</tr>
<tr>
<td>h</td>
<td>short</td>
<td>整数</td>
<td>2</td>
<td>(3)</td>
</tr>
<tr>
<td>H</td>
<td>unsigned short</td>
<td>整数</td>
<td>2</td>
<td>(3)</td>
</tr>
<tr>
<td>i</td>
<td>int</td>
<td>整数</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td>I</td>
<td>unsigned int</td>
<td>整数</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td>l</td>
<td>long</td>
<td>整数</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td>L</td>
<td>unsigned long</td>
<td>整数</td>
<td>4</td>
<td>(3)</td>
</tr>
<tr>
<td>q</td>
<td>long long</td>
<td>整数</td>
<td>8</td>
<td>(2), (3)</td>
</tr>
<tr>
<td>Q</td>
<td>unsigned long long</td>
<td>整数</td>
<td>8</td>
<td>(2), (3)</td>
</tr>
<tr>
<td>f</td>
<td>float</td>
<td>浮点数</td>
<td>4</td>
<td>(4)</td>
</tr>
<tr>
<td>d</td>
<td>double</td>
<td>浮点数</td>
<td>8</td>
<td>(4)</td>
</tr>
<tr>
<td>s</td>
<td>char[]</td>
<td>string</td>
<td></td>
<td></td>
</tr>
<tr>
<td>p</td>
<td>char[]</td>
<td>string</td>
<td></td>
<td></td>
</tr>
<tr>
<td>P</td>
<td>void *</td>
<td>整数</td>
<td></td>
<td>(5), (3)</td>
</tr>
</tbody></table>
<blockquote>
<ol>
<li>‘?’ 转换码对应于 C99 定义的 _Bool 类型。 如果此类型不可用，则使用 char 来模拟。 在标准模式下，它总是以一个字节表示。</li>
</ol>
</blockquote>
<p>2.6 新版功能.</p>
<blockquote>
<ol start="2">
<li>‘q’ 和 ‘Q’ 只有在本地C编译器指出C long long类型行，或者在Windows上支持 __int64的时候才有效。在标准模式下一般都能用。</li>
</ol>
</blockquote>
<p>2.2 新版功能.</p>
<blockquote>
<ol start="3">
<li>在使用任何整形转码的来包装非整形的时候，如果这个非整形有 <code>__index__()</code> 方法，那么在包装之前会调用此方法来转换参数。 如果没有 <code>__index__()</code>方法，或者调用 <code>__index__()</code> 发生了 <em>TypeError</em> 错误, 那么就会尝试 <code>__int__()</code>。虽然 <code>__int__()</code> 已经废弃，且会抛出 <em>DeprecationWarning</em>。</li>
</ol>
</blockquote>
<blockquote>
<p>在 2.7 版更改: 2.7中非整数据的 <code>__index__()</code> 全新使用方法。</p>
</blockquote>
<blockquote>
<p>在 2.7 版更改: 在 2.7 版本中, 并不是所有的整形转换都使用 <code>__int__()</code> 方法, <em>DeprecationWarning</em> 只会在 <strong>float</strong> 转换的时候抛出。</p>
</blockquote>
<blockquote>
<ol start="4">
<li>对于 ‘f’ 和 ‘d’ 格式字符, 封包形式用的是 <code>IEEE 754 binary32 (&#39;f&#39;)</code> 或者 <code>binary64 (&#39;d&#39;)</code> 格式, 与平台使用的浮点格式无关。</li>
</ol>
</blockquote>
<blockquote>
<ol start="5">
<li>‘P’ 格式字符仅对本机字节顺序可用（选择为默认或使用 ‘@’ 字节顺序字符）。 字节顺序字符 ‘=’ 选择使用基于主机系统的小端或大端排序。 struct 模块不会将其解读为本机排序，因此 ‘P’ 格式将不可用。</li>
</ol>
</blockquote>
<blockquote>
<p>格式字符之前可以带有整数重复计数。 例如，格式字符串 ‘4h’ 的含义与 ‘hhhh’ 完全相同。</p>
</blockquote>
<blockquote>
<p>格式之间的空白字符会被忽略；但是计数及其格式字符中不可有空白字符。</p>
</blockquote>
<blockquote>
<p>对于 ‘?’ 格式字符，返回值为 True 或 False。 在打包时将会使用参数对象的逻辑值。 以本机或标准 bool 类型表示的 0 或 1 将被打包，任何非零值在解包时将为 True。</p>
</blockquote>
<blockquote>
<p>对于 ‘s’ 格式字符, 个数会解释为字符串的尺寸, 不想其他格式字符一样转换为重复次数; 例如, ‘10s’ 表示的是一个简单的 <em>10-字节字符串</em>, 但是 ‘10c’ 指的是 10 字符。如果没有指定个数的话，默认就是1。为了便于封包，字符串会被截断或者用空字节来填充来适配。对于解包，还是会根据指定的字节数完美的解出字符串。作为特里，’0s’ 意味着一个单个的空的字符串(而 ‘0c’ 代表 0 个字符).</p>
</blockquote>
<blockquote>
<p>对于’p’ 格式字符对一个 <strong>“Pascal string”</strong> 编码, 意味着一个短的可变长度的字符串存储在一段指定长度的字节中。第一个字节存储的是字符串的长度，或者是255，无论如何都比255小。接下来的字节都是字符串的字节了。如果传入 <code>pack()</code> 的字符串太长 (比count - 1还要长), 那么只会存储字符串前面的 count-1 字节。如果字符串比 count-1 , 那么会用空字节来填充，这样一来就可以用精确的字节数。注意，对于 <code>unpack()</code>,  ‘p’ 格式字符需要消费 <em>count</em> 字节,但是字符串永远都不要超过255个字符。</p>
</blockquote>
<blockquote>
<p>对于 ‘P’ 格式字符，返回值是一个 Python 整形或者长整形，这取决于在转换为整形之后返回的指针的需要的大小。 <em>NULL</em> 指针永远是返回 <strong>Python</strong> 整数 0。在封包指针大小的值的时候， 会用到 <em>Python</em> 整形或者长整形。例如： Alpha 和 Merced 处理器使用的是 64-bit 指针值，意味着会用一个 Python 长整型来持有这个指针; 其他平台使用的是 32-bit 指针，那么他会用 Python 整形。</p>
</blockquote>
<p><a target="_blank" rel="external nofollow noopener noreferrer" href="https://docs.python.org/zh-cn/2.7/library/struct.html">Python 2.7 struct</a></p>
<h2 id="Tornado"><a href="#Tornado" class="headerlink" title="Tornado"></a>Tornado</h2><h3 id="WebSocket的使用方式"><a href="#WebSocket的使用方式" class="headerlink" title="WebSocket的使用方式"></a>WebSocket的使用方式</h3><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> tornado</span><br><span class="line"><span class="keyword">import</span> tornado.httpserver</span><br><span class="line"><span class="keyword">import</span> tornado.ioloop</span><br><span class="line"></span><br><span class="line">app = tornado.web.Application([</span><br><span class="line">    (<span class="string">r&quot;/&quot;</span>, tornado.websocket.WebSocketHandlerExtended),</span><br><span class="line">])</span><br><span class="line"></span><br><span class="line">self._http_server = tornado.httpserver.HTTPServer(app)</span><br><span class="line">self._http_server.bind(port) <span class="comment"># websocket 端口</span></span><br><span class="line">self._http_server.start(num_processes) <span class="comment">#num_processes子进程数</span></span><br><span class="line">tornado.ioloop.IOLoop.instance().start()</span><br></pre></td></tr></table></figure>

<h2 id="greenlet"><a href="#greenlet" class="headerlink" title="greenlet"></a>greenlet</h2><p>轻量级协程，<em>gevent</em> 也是用的 <em>greenlet</em></p>
<ol>
<li>经常与线程 <em>threads</em>,或者<strong>Python</strong>内置的携程<code>async def</code>配合使用</li>
<li>多线程有并发性的问题，需要用 <em>queue</em> 或者 <em>locks</em> 来避免 <em>race condition</em>,<em>deadlock</em> 以及其他的问题。<em>greenlet</em>之间是有序协作的，同时只能有一个<em>greenlet</em>运行。可以完全控制<em>greenlet</em>的切换，从而解决了竞态条件问题。</li>
<li>线程需要申请系统资源，如线程栈，系统预留，而 <em>greenlet</em> 只需要很少的资源</li>
</ol>
<p><code>greenlet().switch()</code>切换到这个调用 <code>switch</code> 的协程</p>
<p><a target="_blank" rel="external nofollow noopener noreferrer" href="https://greenlet.readthedocs.io/en/latest/">greenlet</a></p>
<h2 id="Python-编码出错的问题"><a href="#Python-编码出错的问题" class="headerlink" title="Python 编码出错的问题"></a>Python 编码出错的问题</h2><p>文件头里有</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/env python</span></span><br><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br></pre></td></tr></table></figure>
<p>VS Code工具栏也显示的 <em>UTF-8</em>,那么看看控制台是否有乱码，有的话运行：<code>chcp 65001</code> 试试看</p>
<h2 id="之前面试被问到过的MySQL引擎问题"><a href="#之前面试被问到过的MySQL引擎问题" class="headerlink" title="之前面试被问到过的MySQL引擎问题"></a>之前面试被问到过的MySQL引擎问题</h2><p><a target="_blank" rel="external nofollow noopener noreferrer" href="https://www.imooc.com/article/269997">MySQL引擎介绍</a></p>
<h2 id="collections库"><a href="#collections库" class="headerlink" title="collections库"></a>collections库</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Counter</span></span><br><span class="line">c = collections.Counter(<span class="string">&quot;hello world, hello world,hello world,hello &quot;</span>)</span><br><span class="line"><span class="built_in">print</span> c</span><br><span class="line"><span class="comment"># 查看元素</span></span><br><span class="line"><span class="built_in">print</span> <span class="built_in">list</span>(c.elements())</span><br><span class="line"><span class="comment"># 获取元素的个数，也可以用get()</span></span><br><span class="line"><span class="built_in">print</span> c[<span class="string">&quot;h&quot;</span>]</span><br><span class="line">c = collections.Counter(<span class="string">&quot;hello world hello world hello &quot;</span>.split())</span><br><span class="line"><span class="built_in">print</span> c</span><br><span class="line"><span class="comment"># c.update()</span></span><br><span class="line"><span class="comment"># defaultdict:指定value类型，不存在的给初始值</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p> Counter({‘l’: 11, ‘o’: 7, ‘ ‘: 5, ‘e’: 4, ‘h’: 4, ‘d’: 3, ‘,’: 3, ‘r’: 3, ‘w’: 3})</p>
</blockquote>
<blockquote>
<p>[‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘ ‘, ‘e’, ‘e’, ‘e’, ‘e’, ‘d’, ‘d’, ‘d’, ‘h’, ‘h’, ‘h’, ‘h’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘l’, ‘o’, ‘o’, ‘o’, ‘o’, ‘o’, ‘o’, ‘o’, ‘,’, ‘,’, ‘,’, ‘r’, ‘r’, ‘r’, ‘w’, ‘w’, ‘w’]</p>
</blockquote>
<blockquote>
<p>4</p>
</blockquote>
<blockquote>
<p>Counter({‘hello’: 3, ‘world’: 2})</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">d = collections.defaultdict(<span class="built_in">int</span>)</span><br><span class="line">d[<span class="string">&quot;a&quot;</span>] += <span class="number">2</span></span><br><span class="line"><span class="built_in">print</span> d</span><br><span class="line">s = [(<span class="string">&quot;a&quot;</span>,<span class="string">&quot;b&quot;</span>),(<span class="string">&quot;b&quot;</span>,<span class="string">&quot;c&quot;</span>),(<span class="string">&quot;a&quot;</span>,<span class="string">&quot;c&quot;</span>),(<span class="string">&quot;a&quot;</span>,<span class="string">&quot;d&quot;</span>)]</span><br><span class="line">d = collections.defaultdict(<span class="built_in">list</span>)</span><br><span class="line"><span class="keyword">for</span> k,v <span class="keyword">in</span> s:</span><br><span class="line">    d[k].append(v)</span><br><span class="line"><span class="built_in">print</span> d</span><br></pre></td></tr></table></figure>
<blockquote>
<p>defaultdict(&lt;type ‘int’&gt;, {‘a’: 2})</p>
</blockquote>
<blockquote>
<p>defaultdict(&lt;type ‘list’&gt;, {‘a’: [‘b’, ‘c’, ‘d’], ‘b’: [‘c’]})</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># OrderedDict:保留添加顺序</span></span><br><span class="line">o = collections.OrderedDict()</span><br><span class="line">o[<span class="string">&quot;1&quot;</span>] = <span class="number">1</span></span><br><span class="line">o[<span class="string">&quot;3&quot;</span>] = <span class="number">3</span></span><br><span class="line">o[<span class="string">&#x27;2&#x27;</span>]=<span class="number">2</span></span><br><span class="line">o[<span class="string">&quot;10&quot;</span>]=<span class="number">10</span></span><br><span class="line">o[<span class="string">&quot;8&quot;</span>]=<span class="number">8</span></span><br><span class="line">o[<span class="string">&quot;1&quot;</span>]=<span class="number">100</span> <span class="comment">#重复赋值不会重新排序</span></span><br><span class="line"><span class="built_in">print</span> o</span><br></pre></td></tr></table></figure>
<blockquote>
<p>OrderedDict([(‘1’, 100), (‘3’, 3), (‘2’, 2), (‘10’, 10), (‘8’, 8)])</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># namedtuple(命名元组的构造器)</span></span><br><span class="line"><span class="comment"># 3种命名元组的方法</span></span><br><span class="line">p = collections.namedtuple(<span class="string">&quot;Person&quot;</span>,[<span class="string">&quot;age&quot;</span>,<span class="string">&quot;height&quot;</span>,<span class="string">&quot;name&quot;</span>])</span><br><span class="line"><span class="built_in">print</span> p</span><br><span class="line">h = collections.namedtuple(<span class="string">&quot;Human&quot;</span>,<span class="string">&quot;age, height, name&quot;</span>)</span><br><span class="line">Human1 = collections.namedtuple(<span class="string">&quot;Human1&quot;</span>, <span class="string">&quot;age height name&quot;</span>)</span><br><span class="line">tom = p(<span class="number">30</span>, <span class="number">178</span>, <span class="string">&quot;Tom&quot;</span>)</span><br><span class="line"><span class="built_in">print</span> tom</span><br><span class="line"><span class="built_in">print</span> tom.age</span><br></pre></td></tr></table></figure>
<blockquote>
<p>&lt;class ‘<strong>main</strong>.Person’&gt;</p>
</blockquote>
<blockquote>
<p>Person(age=30, height=178, name=’Tom’)</p>
</blockquote>
<blockquote>
<p>30</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># deque 返回一个新的双向队列对象，支持线程安全，对于两端添加或者弹出，时间复杂度O(1)</span></span><br><span class="line"><span class="comment"># 虽然list对象也支持类似操作，但是这里优化了定长操作（pop(0)、insert(0,v)）的开销</span></span><br><span class="line"><span class="comment"># 没指定maxLen，可以增长到任意长度，定长的如果满了会从另一端弹出</span></span><br><span class="line">dq = collections.deque(maxlen=<span class="number">6</span>)</span><br><span class="line"><span class="built_in">print</span> dq</span><br><span class="line">dq.extend(<span class="string">&#x27;python&#x27;</span>) <span class="comment"># 从队列右侧添加iterable中的元素</span></span><br><span class="line"><span class="built_in">print</span> dq</span><br><span class="line">dq.append(<span class="string">&quot;he&quot;</span>) <span class="comment"># 添加到右侧</span></span><br><span class="line"><span class="built_in">print</span> dq</span><br><span class="line">dq.appendleft(<span class="string">&quot;ma&quot;</span>) <span class="comment"># 添加做左侧</span></span><br><span class="line"><span class="built_in">print</span> dq</span><br></pre></td></tr></table></figure>
<blockquote>
<p>deque([], maxlen=6)</p>
</blockquote>
<blockquote>
<p>deque([‘p’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’], maxlen=6)</p>
</blockquote>
<blockquote>
<p>deque([‘y’, ‘t’, ‘h’, ‘o’, ‘n’, ‘he’], maxlen=6)</p>
</blockquote>
<blockquote>
<p>deque([‘ma’, ‘y’, ‘t’, ‘h’, ‘o’, ‘n’], maxlen=6)</p>
</blockquote>
<h2 id="装饰器"><a href="#装饰器" class="headerlink" title="装饰器"></a>装饰器</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#!/usr/bin/env python</span></span><br><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">a_new_decorator</span>(<span class="params">a_func</span>):</span></span><br><span class="line">    <span class="keyword">from</span> functools <span class="keyword">import</span> wraps</span><br><span class="line">    <span class="comment"># 不加合格的话在外头打印func.__name__会打印到这里来</span></span><br><span class="line"><span class="meta">    @wraps(<span class="params">a_func</span>)</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">warp_the_func</span>():</span></span><br><span class="line">        <span class="built_in">print</span> <span class="string">&quot;Wrap Layer1 begin&quot;</span></span><br><span class="line">        a_func()</span><br><span class="line">        <span class="built_in">print</span> <span class="string">&quot;Wrap Layer end&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> warp_the_func</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">func_need_decotator</span>():</span></span><br><span class="line">    <span class="built_in">print</span> <span class="string">&quot;Func Main&quot;</span></span><br><span class="line"></span><br><span class="line">func_need_decotator()</span><br><span class="line"><span class="built_in">print</span> <span class="string">&quot;-----------------------------&quot;</span></span><br><span class="line">func_decotated = a_new_decorator(func_need_decotator)</span><br><span class="line">func_decotated()</span><br><span class="line"></span><br><span class="line"><span class="built_in">print</span> <span class="string">&quot;-----------------------------&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="meta">@a_new_decorator</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">fun_with_decorator</span>():</span></span><br><span class="line">    <span class="built_in">print</span> <span class="string">&quot;Hehe&quot;</span></span><br><span class="line"></span><br><span class="line">fun_with_decorator()</span><br></pre></td></tr></table></figure>
<blockquote>
<h2 id="Func-Main"><a href="#Func-Main" class="headerlink" title="Func Main"></a>Func Main</h2><p>Wrap Layer1 begin<br>Func Main<br>Wrap Layer end</p>
<hr>
<p>Wrap Layer1 begin<br>Hehe<br>Wrap Layer end</p>
</blockquote>
<h2 id="Java注解"><a href="#Java注解" class="headerlink" title="Java注解"></a>Java注解</h2><h3 id="标记注解"><a href="#标记注解" class="headerlink" title="标记注解"></a>标记注解</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//有点像定义一个接口一样，只不过它多了一个@</span></span><br><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MyAnnotation &#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h3 id="元数据注解"><a href="#元数据注解" class="headerlink" title="元数据注解"></a>元数据注解</h3><h4 id="普通使用"><a href="#普通使用" class="headerlink" title="普通使用"></a>普通使用</h4><h5 id="定义"><a href="#定义" class="headerlink" title="定义"></a>定义</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MyAnnotation &#123;</span><br><span class="line">    <span class="comment">//定义了两个成员变量</span></span><br><span class="line">    <span class="function">String <span class="title">username</span><span class="params">()</span></span>;</span><br><span class="line">    <span class="function"><span class="keyword">int</span> <span class="title">age</span><span class="params">()</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">//注解拥有什么属性，在修饰的时候就要给出相对应的值</span></span><br><span class="line"><span class="meta">@MyAnnotation(username = &quot;zhongfucheng&quot;, age = 20)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">add</span><span class="params">(String username, <span class="keyword">int</span> age)</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="默认值"><a href="#默认值" class="headerlink" title="默认值"></a>默认值</h4><h5 id="定义-1"><a href="#定义-1" class="headerlink" title="定义"></a>定义</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MyAnnotation &#123;</span><br><span class="line">    <span class="comment">//定义了两个成员变量</span></span><br><span class="line">    <span class="function">String <span class="title">username</span><span class="params">()</span> <span class="keyword">default</span> &quot;zicheng&quot;</span>;</span><br><span class="line">    <span class="function"><span class="keyword">int</span> <span class="title">age</span><span class="params">()</span> <span class="keyword">default</span> 23</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="使用-1"><a href="#使用-1" class="headerlink" title="使用"></a>使用</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@MyAnnotation()</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">add</span><span class="params">(String username, <span class="keyword">int</span> age)</span> </span>&#123;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h4 id="注解为Value"><a href="#注解为Value" class="headerlink" title="注解为Value"></a>注解为Value</h4><h5 id="定义-2"><a href="#定义-2" class="headerlink" title="定义"></a>定义</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MyAnnotation2 &#123;</span><br><span class="line">    <span class="function">String <span class="title">value</span><span class="params">()</span></span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h5 id="使用-2"><a href="#使用-2" class="headerlink" title="使用"></a>使用</h5><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@MyAnnotation2(&quot;zhongfucheng&quot;)</span></span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">find</span><span class="params">(String id)</span> </span>&#123;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<ul>
<li>来源： <a target="_blank" rel="external nofollow noopener noreferrer" href="https://www.jianshu.com/p/89f4c9d7d37b">注解就这么简单</a></li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/python/" rel="tag"># python</a>
              <a href="/tags/tornado/" rel="tag"># tornado</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2022/03/21/everydayprogress029/" rel="prev" title="每天进步一点点029 - Python数据科学教程的学习">
      <i class="fa fa-chevron-left"></i> 每天进步一点点029 - Python数据科学教程的学习
    </a></div>
      <div class="post-nav-item">
    <a href="/2022/05/13/everydayprogress031/" rel="next" title="每天进步一点点031 - 尝试一下OCR">
      每天进步一点点031 - 尝试一下OCR <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%BF%83%E5%BE%97"><span class="nav-number">1.</span> <span class="nav-text">心得</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#ImportError-No-module-named-xxxxx"><span class="nav-number">1.1.</span> <span class="nav-text">ImportError: No module named xxxxx</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#tornado-queuetornado-queue"><span class="nav-number">1.2.</span> <span class="nav-text">tornado.queuetornado.queue</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#tornado-web%E5%BA%94%E7%94%A8%E7%9A%84%E7%BB%93%E6%9E%84"><span class="nav-number">1.3.</span> <span class="nav-text">tornado web应用的结构</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#setproctitle"><span class="nav-number">1.4.</span> <span class="nav-text">setproctitle</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#struct"><span class="nav-number">1.5.</span> <span class="nav-text">struct</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%A4%B4%E5%AD%97%E7%AC%A6%EF%BC%9A%E8%A1%A8%E7%A4%BA%E5%AD%97%E8%8A%82%E9%A1%BA%E5%BA%8F%EF%BC%8C%E5%A4%A7%E5%B0%8F%E5%92%8C%E5%AF%B9%E9%BD%90%E6%96%B9%E5%BC%8F"><span class="nav-number">1.5.1.</span> <span class="nav-text">头字符：表示字节顺序，大小和对齐方式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%BC%E5%BC%8F%E5%AD%97%E7%AC%A6"><span class="nav-number">1.5.2.</span> <span class="nav-text">格式字符</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Tornado"><span class="nav-number">1.6.</span> <span class="nav-text">Tornado</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#WebSocket%E7%9A%84%E4%BD%BF%E7%94%A8%E6%96%B9%E5%BC%8F"><span class="nav-number">1.6.1.</span> <span class="nav-text">WebSocket的使用方式</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#greenlet"><span class="nav-number">1.7.</span> <span class="nav-text">greenlet</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Python-%E7%BC%96%E7%A0%81%E5%87%BA%E9%94%99%E7%9A%84%E9%97%AE%E9%A2%98"><span class="nav-number">1.8.</span> <span class="nav-text">Python 编码出错的问题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B9%8B%E5%89%8D%E9%9D%A2%E8%AF%95%E8%A2%AB%E9%97%AE%E5%88%B0%E8%BF%87%E7%9A%84MySQL%E5%BC%95%E6%93%8E%E9%97%AE%E9%A2%98"><span class="nav-number">1.9.</span> <span class="nav-text">之前面试被问到过的MySQL引擎问题</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#collections%E5%BA%93"><span class="nav-number">1.10.</span> <span class="nav-text">collections库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%A3%85%E9%A5%B0%E5%99%A8"><span class="nav-number">1.11.</span> <span class="nav-text">装饰器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Func-Main"><span class="nav-number">1.12.</span> <span class="nav-text">Func Main</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Java%E6%B3%A8%E8%A7%A3"><span class="nav-number">1.13.</span> <span class="nav-text">Java注解</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%A0%87%E8%AE%B0%E6%B3%A8%E8%A7%A3"><span class="nav-number">1.13.1.</span> <span class="nav-text">标记注解</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E5%85%83%E6%95%B0%E6%8D%AE%E6%B3%A8%E8%A7%A3"><span class="nav-number">1.13.2.</span> <span class="nav-text">元数据注解</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%99%AE%E9%80%9A%E4%BD%BF%E7%94%A8"><span class="nav-number">1.13.2.1.</span> <span class="nav-text">普通使用</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%AE%9A%E4%B9%89"><span class="nav-number">1.13.2.1.1.</span> <span class="nav-text">定义</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8"><span class="nav-number">1.13.2.1.2.</span> <span class="nav-text">使用</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E9%BB%98%E8%AE%A4%E5%80%BC"><span class="nav-number">1.13.2.2.</span> <span class="nav-text">默认值</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%AE%9A%E4%B9%89-1"><span class="nav-number">1.13.2.2.1.</span> <span class="nav-text">定义</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8-1"><span class="nav-number">1.13.2.2.2.</span> <span class="nav-text">使用</span></a></li></ol></li><li class="nav-item nav-level-4"><a class="nav-link" href="#%E6%B3%A8%E8%A7%A3%E4%B8%BAValue"><span class="nav-number">1.13.2.3.</span> <span class="nav-text">注解为Value</span></a><ol class="nav-child"><li class="nav-item nav-level-5"><a class="nav-link" href="#%E5%AE%9A%E4%B9%89-2"><span class="nav-number">1.13.2.3.1.</span> <span class="nav-text">定义</span></a></li><li class="nav-item nav-level-5"><a class="nav-link" href="#%E4%BD%BF%E7%94%A8-2"><span class="nav-number">1.13.2.3.2.</span> <span class="nav-text">使用</span></a></li></ol></li></ol></li></ol></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="ado" src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">ado</p>
  <div class="site-description" itemprop="description">me, robot.</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">94</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">60</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/adoontheway" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://gitee.com/adoontheway" title="Gitee → https:&#x2F;&#x2F;gitee.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-github"></i>Gitee</a>
      </span>
      <span class="links-of-author-item">
        <a href="http://cnblogs.com/adoontheway" title="Cnblogs → http:&#x2F;&#x2F;cnblogs.com&#x2F;adoontheway" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-cnblogs"></i>Cnblogs</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://legacy.gitbook.com/@adobeattheworld" title="Gitbook → https:&#x2F;&#x2F;legacy.gitbook.com&#x2F;@adobeattheworld" rel="external nofollow noopener noreferrer" target="_blank"><i class="fa fa-fw fa-gitbook"></i>Gitbook</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">ado</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="external nofollow noopener noreferrer" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="external nofollow noopener noreferrer" target="_blank">NexT.Muse</a> 强力驱动
  </div>



        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="//fastly.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  











<script>
document.querySelectorAll('.pdfobject-container').forEach(element => {
  let url = element.dataset.target;
  let pdfOpenParams = {
    navpanes : 0,
    toolbar  : 0,
    statusbar: 0,
    pagemode : 'thumbs',
    view     : 'FitH'
  };
  let pdfOpenFragment = '#' + Object.entries(pdfOpenParams).map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
  let fullURL = `/lib/pdf/web/viewer.html?file=${encodeURIComponent(url)}${pdfOpenFragment}`;

  if (NexT.utils.supportsPDFs()) {
    element.innerHTML = `<embed class="pdfobject" src="${url + pdfOpenFragment}" type="application/pdf" style="height: ${element.dataset.height};">`;
  } else {
    element.innerHTML = `<iframe src="${fullURL}" style="height: ${element.dataset.height};" frameborder="0"></iframe>`;
  }
});
</script>


<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//unpkg.com/mermaid@8.14.0/dist/mermaid.min.js', () => {
    mermaid.initialize({
      theme    : '',
      logLevel : 3,
      flowchart: { curve     : 'linear' },
      gantt    : { axisFormat: '%m/%d/%Y' },
      sequence : { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>


  

  

</body>
</html>
